package client;

import metier.UserBean;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.*;
import java.net.*;

import javax.jnlp.BasicService;
import javax.jnlp.ServiceManager;

public class ConnecterBehavior implements ActionListener {

	public void actionPerformed(ActionEvent ae)
	{
		try{
			BasicService bs = (BasicService)ServiceManager.lookup("javac.jnlp.BasicService");
			URL servletURL = new URL(bs.getCodeBase(),"servletConnexion");
			//bs : http://localhost:8080/
			URLConnection conX = servletURL.openConnection();
			conX.setDoOutput(true); //config de la connexion
			OutputStream os = conX.getOutputStream();
			OutputStreamWriter osw = new OutputStreamWriter(os);
			osw.write("Connexion");
			osw.flush();
			osw.close();

			InputStream is = conX.getInputStream() ;
			ObjectInputStream ois = new ObjectInputStream(is) ;
			UserBean ub = (UserBean) ois.readObject() ;

		}
		catch(Exception e){};
	}
}
